
<?php $pageName="business";?> 
<?php require_once('header.php'); ?>    
   


<div class="repCont brd">

<?php     
$busId  = trim( Request::getVar('busId') ); // (isset($_GET['busId']))? $_GET['busId']:"" ; 
$action  = trim( Request::getVar('busAct') ); //(isset($_GET['busAct']))? $_GET['busAct']:"" ; 

$wella = new Base();

if ($action=='save' || $action=='update'){
      

       // echo "save";

            $busTitle  = trim( Request::getVar('busTitle') );
            $busDesc  = trim( Request::getVar('busDesc') );
            $busScenarios  = trim( Request::getVar('busScenarios') );
            $busId  = ( Request::getVar('busId') )? trim( Request::getVar('busId') ): 0;
            
                                                                                  
           
           
            $wella->saveBusiness($busId,$busTitle,$busDesc,$busScenarios, 'save'); 
            
            
          

   
   
    
}

//else{

 if ((intval($busId)>0) && $action=='editBus'){
    
 $busObj  = $wella->getBusinesses($busId) ;
 
 $busTitle    = $busObj[0][1];  
 $busDesc    = $busObj[0][2];
 $busScenarios    = $busObj[0][3];
 //var_dump($busObj) ;
    
?>                                                                                      
 <form method="post" action="showBusiness.php" id="busForm" enctype="multipart/form-data"> 
            <fieldset> 
            
            <input type="hidden" id="busId" name="busId" value="<?php echo $busId;?>" /> 
            <input type="hidden" id="busScenarios" name="busScenarios" value="<?php echo $busScenarios;?>" /> 
            
            <input type="hidden" id="busAct" name="busAct" value="save" /> 
            

                <div class="fItem">
                    <span for="">Edit  Business:  </span>
                    
                </div>
                
                <div class="fItem">
                    <label for="rTitle">Business Title:</label>
                    <input type="text" id="busTitle" name="busTitle"  value="<?php echo $busTitle;?>" />
                </div>

                <div class="fItem">
                    <label for="rDesc">Business Description:</label>
                    <textarea id="busDesc" name="busDesc" class"tArea"><?php echo $busDesc;?></textarea>
                </div>

                <div class="fItem">
                    <label for="rUrl">Business Scenarios: </label>
                    <div class="bus-list">
<?php
   $scenarios = $wella->getScenarios();
   //var_dump($scenarios);
   $busScenariosSelected = explode(',',$busScenarios)  ;
   
   if (sizeof($scenarios)>0){
       foreach($scenarios as $scenario)   {
        $strChecked = '';
        if (in_array($scenario[0],$busScenariosSelected ) ){
        $strChecked = ' checked="checked"';
        }
?>

                        
                        <div class="fItem"> 
                        <input type="checkbox" class="bChk" id="busScn_<?php echo $scenario[0];?>" name="busScn_<?php echo $scenario[0];?>"  value="<?php echo $scenario[0];?>"<?php echo $strChecked;?> /> <label for="busScn_<?php echo $scenario[0];?>"> <?php echo $scenario[1];?></label><br />
                        </div>  
                        
<?php
       }
   }
?>
                         
                    </div> 
                </div>

               

                <div class="fItem actButCont">  
                <div class="rgt">                                                                       
                    <input type="button" class="actbutton" id="busDelete" name="busDelete" value="Delete" />
                    <input type="reset" class="actbutton" id="busCancel" name="busCancel" value="Cancel" />
                    <input type="button" class="actbutton" id="busSubmit" name="busSubmit" value="Save" />
                </div>
                </div>

            </fieldset>

  </form>
  

<?php
    
    
}else if (intval($busId)>0){
   //print_r($from_post);
   
   
    switch($action){
        
                       
        case 'delete':
         $wella->deleteBusiness($busId); 
        
        break;  
             
      
        default:
            $wella->showBusiness($busId, '');
        break;     
      
        
    }
    
}else if($action=='addNew'){
    
    
 ?>                       
 <form method="post" action="showBusiness.php" id="busForm" enctype="multipart/form-data"> 
            <fieldset> 
            
            <input type="hidden" id="busId" name="busId" value="" /> 
            <input type="hidden" id="busScenarios" name="busScenarios" value="" /> 
            
            <input type="hidden" id="busAct" name="busAct" value="save" /> 
            

                <div class="fItem">
                    <span for="">Add New  Business:  </span>
                    
                </div>
                
                <div class="fItem">
                    <label for="rTitle">Business Title:</label>
                    <input type="text" id="busTitle" name="busTitle"  value=""/>
                </div>

                <div class="fItem">
                    <label for="rDesc">Business Description:</label>
                    <textarea id="busDesc" name="busDesc" class"tArea"></textarea>
                </div>

                <div class="fItem">
                    <label for="rUrl">Business Scenarios </label>
                    <div class="bus-list brd">
<?php
   $scenarios = $wella->getScenarios();
   //var_dump($scenarios);
   
   if (sizeof($scenarios)>0){
       foreach($scenarios as $scenario)   {
?>
                        
                        <div class="fItem"> 
                        <input type="checkbox" class="bChk" id="busScn_<?php echo $scenario[0];?>" name="busScn_<?php echo $scenario[0];?>"  value="<?php echo $scenario[0];?>"/> <label for="busScn_<?php echo $scenario[0];?>"> <?php echo $scenario[1];?></label><br />
                        </div>  
                        
<?php
       }
   }
?>
                         
                    </div> 
                </div>

               

                <div class="fItem actButCont">  
                <div class="rgt">                                                                       
                    <input type="button" class="actbutton" id="busSubmit" name="busSubmit" value="Save" />
                </div>
                </div>

            </fieldset>

  </form>
  

 <?php
    
 
   
}else{
?>

<h2>Businesses: </h2><br/>

<?php     
      //print_r($from_post);
   $wella = new Base();
   $wella->showBusinessLinks();

?>  

<?php
    
}
//}
?>
 



</div>  
 <?php require_once('links.php'); ?> 
 
<?php require_once('footer.php'); ?>   